home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2 Examples.sit
/
Raven 1.2 Examples
/
Quill
/
Source
/
ViewWindow.cpp
< prev
next >
Wrap
Text File
|
1997-08-09
|
3KB
|
121 lines
/*
* File: ViewWindow.cpp
* Summary: The default window panes are edited in.
* Written by: Jesse Jones
*
* Copyright ゥ 1996 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <-> 9/02/96 JDJ Created
*/
#include "ViewWindow.h"
#include <List.h>
#include <ZApplication.h>
#include <ZAttribute.h>
#include <ZIntConversions.h>
#include <ZQDShapes.h>
#include <ZStringUtils.h>
#include "ResourceMap.h"
#include "ViewContainer.h"
// ===================================================================================
// class CViewWindow
// ===================================================================================
//---------------------------------------------------------------
//
// CViewWindow::~CViewWindow
//
//---------------------------------------------------------------
CViewWindow::~CViewWindow()
{
// Delete the view container while we're still the right type.
this->DoDeleteSubPanes();
}
//---------------------------------------------------------------
//
// CViewWindow::CViewWindow
//
//---------------------------------------------------------------
CViewWindow::CViewWindow(const SWindowInfo& info, CResourceMap* rsrcMap, ResID id, MCommander* superCommander) : TWindow(info, superCommander)
{
ASSERT(rsrcMap != nil);
mRsrcMap = rsrcMap;
mRsrcID = id;
this->AddAttribute("Editing", new TAttribute(kNonPersistant));
CViewContainer* view = new CViewContainer(this, mRsrcMap, mRsrcID);
this->UpdateTitle();
mRsrcMap->AddListener(this);
}
//---------------------------------------------------------------
//
// CViewWindow::UpdateTitle
//
//---------------------------------------------------------------
void CViewWindow::UpdateTitle()
{
string title = LoadIndString(257, 1) + " " + ShortToStr(mRsrcID) + ", ¥"";
title += mRsrcMap->GetResourceName(mRsrcID) + "¥"";
this->SetName(title);
}
//---------------------------------------------------------------
//
// CViewWindow::Invariant
//
//---------------------------------------------------------------
void CViewWindow::Invariant() const
{
Inherited::Invariant();
ASSERT(mRsrcMap != nil);
if (mSubPanes->size() > 0) {
ASSERT(mSubPanes->size() == 1);
TPane* subPane = mSubPanes->front();
ASSERT(subPane != nil);
ASSERT(dynamic_cast<CViewContainer*>(subPane) != nil);
}
}
//---------------------------------------------------------------
//
// CViewWindow::OnBroadcast
//
//---------------------------------------------------------------
void CViewWindow::OnBroadcast(const SResourceMapMessage& mesg)
{
if (mesg.rsrcMap == mRsrcMap) {
if (mesg.message == kSetResourceName)
this->UpdateTitle();
else if (mesg.message == kSetResourceID && mesg.oldRsrc.id == mRsrcID) {
mRsrcID = mesg.newRsrc.id;
this->UpdateTitle();
}
}
}